<?php get_header(); ?>
<div class="cy-content">
	<?php get_sidebar();?>
    <div class="cy-content-center">
    <div class="cy-content-search">
    TÌM KIẾM : 
      <select name="theoten" id="theoten">
      <option value="#">Tìm theo tên</option>
      </select>
      <select name="theogia" id="theogia">
      <option value="#">Tìm theo giá</option>
      </select>
    </div><!--cy-content-search-->
    <div class="cy-content-title">
    <h2>camera quan sát</h2>
    </div><!--cy-content-title-->
    <ul class="cy-products">
    <?php 	  
    // Get terms for post
	$terms = get_terms("danh_muc_san_pham");
				 $count = count($terms);
				 if ( $count > 0 ){
				foreach ( $terms as $term ) {	
   				?>
       <li>
            <div class="cy-product-title">
                <?php 
    				echo  $term->name;
    			?>
                | 	
                <ul id="tab_product" class="tab_product">
                <?php
            	$loop = new WP_Query(array('post_type'=>'san_pham','danh_muc_san_pham'=>$term->slug,'order'=>'DESC'));?>
                <?php while ( $loop->have_posts() ) : $loop->the_post(); //bat dau vong lap ?>
                    <li><a href="#<?php echo $post->ID;?>"><?php the_title();?></a></li>
                    <?php endwhile; //ket thuc vong lap ?>
                    <?php wp_reset_query();?>
    			</ul>
            </div><!--cy-product-title-->
            
            <?php
            $loop1 = new WP_Query(array('post_type'=>'san_pham','danh_muc_san_pham'=>$term->slug,'order'=>'DESC'));?>
            <?php while ( $loop->have_posts() ) : $loop->the_post(); //bat dau vong lap 
             ?>
             
                <div id="<?php echo $post->ID;?>"  class="cy-product-content">
                <img src="<?php echo get('hinh');?>" />
                
                        <ul class="cy-product-content-i" >
                            <li><a href="<?php the_permalink();?>">Mã sản phẩm :</a> <?php echo get('ma_san_pham');?></li>
                            <li>Đơn vị tính : <?php echo get('don_vi_tinh');?></li>
                            <li>Xuất xứ : <?php echo get('xuat_xu');?></li>
                            <li>Trạng thái: <?php if(get('trang_thai')==0){echo "Còn hàng";}else{echo "Hết hàng";};?></li>
                        </ul><!--cy-product-content-->
                        <div class="cy-read-more">
                        </div><!--cy-read-more-->
    					<?php if(trim(get('gia_khuyen_mai')) !=""){?>
                         <div class="cy-price-gach">
                         Giá : <?php echo get('gia');?>
                         </div><!--cy-price-gach-->
                         <div class="cy-price-km">
                         Giá khuyến mãi : <?php echo get('gia_khuyen_mai');?>
                         </div><!--cy-price-km-->
                        <?php }else{?>
                         <div class="cy-price">
                         Giá : <?php echo get('gia');?>
                         </div><!--cy-price-->
                         <?php } ?>
               </div><!--cy-product-content-->
          <?php  endwhile; 
          //ket thuc vong lap ?>
          <?php wp_reset_query();?>
            
        </li>
        				<?php 
				 }
   				?>
        <?php    
		} ?>
    </ul>
    </div><!--cy-content-center-->  
</div><!--cy-content-->
<?php get_footer(); ?>